/**
 * 
 */
var start =false;
var startX =0,startY =0;
var ctx;
function drawing(){
	
	document.getElementById('canvas').onmousemove =chk;
	document.getElementById('canvas').onmouseup =set;
	ctx = document.getElementById('canvas').getContext("2d"); 
}
//마우스 눌렀다 놨을때
function set(ev){
	var lc;
	var lw;
	start = !start;
	startX = (ev.x-7);
	startY = (ev.y-8);

	//선 그리기 시작 점 설정
	if(start){
		ctx.beginPath();
		ctx.moveTo(startX ,startY);
		lc = document.getElementById('lineColor');
		lw = document.getElementById('lineWidth');
		ctx.strokeStyle = lc.value;
		ctx.lineWidth = lw.value;
		
	}else{
		ctx.closePath();
	}
}
function chk(ev){
	var d = document.getElementById("result");
	var x = ev.x;
	var y = ev.y;
	d.innerHTML ='x'+x+',y'+y;
	if(start){
		ctx.lineTo(x,y);
		ctx.stroke();
	}
	
}